/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.unioeste.cc.vm;

/**
 *
 * @author diego
 */
public class Alu {

    int zero, op1, op2;
    int result;
    int signalAluControl;

    public int getOp1() {
        return op1;
    }

    public void setOp1(int op1) {
        this.op1 = op1;
    }

    public int getOp2() {
        return op2;
    }

    public void setOp2(int op2) {
        this.op2 = op2;
    }

    public int getResult() {
        return result;
    }

    public void setResult(int result) {
        this.result = result;
    }

    public int getSignalAluControl() {
        return signalAluControl;
    }

    public void setSignalAluControl(int signalAluControl) {
        this.signalAluControl = signalAluControl;
    }

    public int getZero() {
        return zero;
    }

    public void setZero(int zero) {
        this.zero = zero;
    }

    void operationAdd() {
        result = op1 + op2;
    }

    void operationSub() {
        result = op1 - op2;
    }

    void operationAnd() {
        result = op1 & op2;
    }

    void operationOr() {
        result = op1 | op2;
    }

    public void execute() {
        switch (signalAluControl) {
            case 0:
                System.out.println("Operation AND");
                operationAnd();
                break;
            case 1:
                System.out.println("Operation OR");
                operationOr();
                break;
            case 2:
                System.out.println("Operation ADD");
                operationAdd();
                break;
            case 6:
                System.out.println("Operation de SUB");
                operationSub();
                break;
            default:
                break;
        }
    }
}
